cd "PATH\TO\FOLDER\WITH\DATA"
use "replication_data.dta", clear
cd "tables"

//FOR PLOT MARKERS
foreach i in D R B F{
gen label_`i'="`i'"
} 

//TREATMENTS/OUTCOMES
tab MIA120_grid, gen(state_outcome)
drop state_outcome1
rename state_outcome2 state_passed

recode MIA120c MIA120d_1 MIA120d_2 MIA120e_1 MIA120e_2 MIA120a MIA120b (1=4) (2=3) (3=2) (4=1), gen(SR_1 SR_2 SR_3 SR_4 SR_5 SR_6 SR_7)
**SR: 1 = mandatory mins; 2 = always allow abortion; 3 = never abortion; 4 = ban assault; 5 = easier conceal; 6 = minimum wage; 7 = work req.
recode CC22_334a CC22_332a CC22_332f CC22_330b CC22_330c (1=1) (2=0) (*=.)
gen agree_state_1 = CC22_334a==state_passed
gen agree_state_2 = CC22_332a==state_passed
gen agree_state_3 = CC22_332f==state_passed
gen agree_state_4 = CC22_330b==state_passed
gen agree_state_5 = CC22_330c==state_passed

//CONSIDER VARIANCE
egen ab_SR = rowmean(SR_2 SR_3)
egen gun_SR = rowmean(SR_4 SR_5)
egen missing=rowmiss(SR_1 SR_6 SR_7 ab_SR gun_SR)
egen sd_SR=rowsd(SR_1 SR_6 SR_7 ab_SR gun_SR)
egen mean_SR=rowmean(SR_1 SR_6 SR_7 ab_SR gun_SR)
egen max_SR=rowmax(SR_1 SR_6 SR_7 ab_SR gun_SR)
egen min_SR=rowmin(SR_1 SR_6 SR_7 ab_SR gun_SR)
gen diff=max_SR-min_SR

label var SR_1 "Mandatory Minimums"
label var SR_2 "Always Permit Abortion"
label var SR_3 "Never Permit Abortion"
label var SR_4 "Ban Assault Rifles"
label var SR_5 "Easier to Conceal/Carry"
label var SR_6 "Minimum Wage \$15"
label var SR_7 "Food Stamp Work Req."


* RESTRICT SAMPLE
reg mean_SR age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other [aw=teamweight], r
keep if e(sample)

qui sum mean_SR
replace mean_SR=(mean_SR-r(mean))/r(sd)
label var mean_SR "Mean Support for Devolution (M = 0; SD = 1)"

**CORRELATIONS FOR SM_B2_Correlations TABLE
pwcorr SR_1 SR_2 SR_3 SR_4 SR_5 SR_6 SR_7 [aw=teamweight]

**TABLE SM.B1: SUMMARY STATS
estpost summarize SR_1 SR_2 SR_3 SR_4 SR_5 SR_6 SR_7 age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other pid [aw=teamweight]
eststo pooled, title("Full Sample")
esttab pooled using "SM_B1_sumstats.tex", cells(mean(fmt(a2))) replace title(Summary Statistics \label{sumstats}) addnote(Cell entries are means.) nogaps booktabs wrap varwidth(40) b(%9.3f) se(%9.3f) nonotes nodepvars label collabel(none)

**INDICATORS FOR WHICH GUN/ABORTION POLICIES ASKED
gen issue_ban_abortion = SR_2==.
gen issue_conceal_carry = SR_4==.
label var issue_ban_abortion "Devolution Q: Ban Abortion"
label var issue_conceal_carry "Devolution Q: Conceal/Carry"

********************************************
** TABLE 1: PID RELATIONSHIP ***************
********************************************
reg mean_SR std_pid  issue_ban_abortion issue_conceal_carry [aw=teamweight], r
estimates store pid_bivar
qui lincom std_pid
local biv=r(estimate)

reg mean_SR age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry std_pid i.inputstate [aw=teamweight], r
estimates store pid_demo
qui lincom std_pid
local demo=r(estimate)

reg mean_SR age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry dich_pid##c.interest i.inputstate [aw=teamweight], r
estimates store pid_interest

reg mean_SR (c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry dich_pid i.inputstate)##c.interest [aw=teamweight], r
estimates store pid_interest_full

//OUTPUT REGRESSIONS
esttab pid_bivar pid_demo pid_interest pid_interest_full using T1_pid_relationships.tex, replace nogaps keep(age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry std_pid 1.dich_pid interest  1.dich_pid#c.interest _cons) order(std_pid 1.dich_pid interest  1.dich_pid#c.interest) compress booktabs wrap varwidth(40) b(%9.3f) se(%9.3f) star(* 0.05 ** .01)  interaction(" $\times$ ")  nonotes label title("Relationship between Party Identification and Support for Devolution"\label{pidrelationships}) addnote("Cell entries are unstandardized OLS coefficients; robust standard errors in parentheses. \linebreak $* p < .05; ** p < .01$.")

***POLITICAL INTEREST MODERATION/CONSIDERING ALTERNATIVES--MODELS
reg mean_SR age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry dich_pid##(c.str_pid) i.inputstate [aw=teamweight], r
estimates store pid_str_pid

reg mean_SR (c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry dich_pid i.inputstate)##c.str_pid [aw=teamweight], r
estimates store pid_str_pid_full

reg mean_SR age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry dich_pid##(c.str_ideol) i.inputstate [aw=teamweight], r
estimates store pid_str_ideol

reg mean_SR (c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry dich_pid i.inputstate)##c.str_ideol [aw=teamweight], r
estimates store pid_str_ideol_full

reg mean_SR age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry dich_pid##(c.interest c.str_pid c.str_ideol) i.inputstate [aw=teamweight], r
estimates store pid_all_mod

reg mean_SR (c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry dich_pid i.inputstate)##(c.interest c.str_pid c.str_ideol) [aw=teamweight], r
estimates store pid_all_mod_full

//TABLE SM.B3: POLITICAL INTEREST MODERATION--CONSIDERING ALTERNATIVE MODERATORS
esttab pid_interest pid_str_pid pid_str_ideol pid_all_mod using SM_B3_alt_moderators.tex, replace nogaps keep(age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry 1.dich_pid interest str_pid str_ideol 1.dich_pid#c.interest 1.dich_pid#c.str_pid 1.dich_pid#c.str_ideol _cons) order(1.dich_pid interest  str_pid str_ideol 1.dich_pid#c.interest 1.dich_pid#c.str_pid 1.dich_pid#c.str_ideol) compress booktabs wrap varwidth(40) b(%9.3f) se(%9.3f) star(* 0.05 ** .01)  interaction(" $\times$ ")  nonotes label title("Party Identification and Support for Devolution (Alternative Moderators)"\label{pidaltmod}) addnote("Cell entries are unstandardized OLS coefficients; robust standard errors in parentheses. \linebreak $* p < .05; ** p < .01$.")

//TABLE SM.B4: POLITICAL INTEREST MODERATION--CONSIDERING ALTERNATIVE MODERATORS, CONTROLLING FOR CONTROL VARIABLE INTERACTIONS
esttab pid_interest_full pid_str_pid_full pid_str_ideol_full pid_all_mod_full using SM_B4_alt_moderators_full.tex, replace nogaps keep(age educ income 1.income_mis 1.woman 1.gend_other 1.r_black 1.r_hisp 1.r_asian 1.r_multiple 1.r_other 1.issue_ban_abortion 1.issue_conceal_carry 1.dich_pid interest str_pid str_ideol 1.dich_pid#c.interest 1.dich_pid#c.str_pid 1.dich_pid#c.str_ideol _cons) order(1.dich_pid interest  str_pid str_ideol 1.dich_pid#c.interest 1.dich_pid#c.str_pid 1.dich_pid#c.str_ideol) compress booktabs wrap varwidth(40) b(%9.3f) se(%9.3f) star(* 0.05 ** .01)  interaction(" $\times$ ")  nonotes label title("Party Identification and Support for Devolution (Alternative Moderators; Control for Moderator x Demographics)"\label{pidaltmodfull}) addnote("Cell entries are unstandardized OLS coefficients; robust standard errors in parentheses. \linebreak $* p < .05; ** p < .01$.")

//NOTE BENCHMARKING PID COEFFICIENT TO MODEL SPECIFYING TAXES/SPENDING TRADEOFF AS OUTCOME (TEXT ACCOMPANYING TABLE 1)
reg taxes std_pid  issue_ban_abortion issue_conceal_carry [aw=teamweight], r
reg taxes age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry std_pid i.inputstate [aw=teamweight], r


//PARTY DIFFERENCES EMERGE ACROSS ISSUES? YES, w EXCEPTION OF FOOD STAMPS
forvalues i=1/7{
qui reg SR_`i' age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry std_ideol independent republican i.inputstate [aw=teamweight], r
lincom republican
}
forvalues i=1/7{
qui reg SR_`i' age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry independent republican i.inputstate [aw=teamweight], r
lincom republican
}

********************************************
** STATE GOV ALIGNMENT MEASURES ************
********************************************

****PERCEIVED STATE CONTROL
gen st_ctrl_rep = (CC22_310c==1 & CC22_310d!=2) | (CC22_310c!=2 & CC22_310d==1) 
gen st_ctrl_dem = (CC22_310c==2 & CC22_310d!=1) | (CC22_310c!=1 & CC22_310d==2) 

gen perc_ctrl = .5
replace perc_ctrl = .75 if (CC22_310c==1 & CC22_310d!=2) | (CC22_310c!=2 & CC22_310d==1) 
replace perc_ctrl = .25 if (CC22_310c==2 & CC22_310d!=1) | (CC22_310c!=1 & CC22_310d==2) 
replace perc_ctrl = 1 if CC22_310c==1 & CC22_310d==1
replace perc_ctrl = 0 if CC22_310c==2 & CC22_310d==2

label var perc_ctrl "Perceived State Control (0 = unified Dem.; 1 = unified Rep.)"
gen perc_ctrl_align_pid = .5
replace perc_ctrl_align_pid = perc_ctrl if republican==1
replace perc_ctrl_align_pid = abs(perc_ctrl-1) if democrat==1
label var perc_ctrl_align_pid "Perc. State Control Aligned w/PID"

///ACTUAL STATE CONTROL
gen act_ctrl=.5
replace act_ctrl = 0 if  LegControl=="Dem"
replace act_ctrl = 1 if  LegControl=="Rep"

gen act_ctrl_align_pid = .5
replace act_ctrl_align_pid = act_ctrl if republican==1
replace act_ctrl_align_pid = abs(act_ctrl-1) if democrat==1
label var act_ctrl_align_pid "Actual State Control Aligned w/PID"

//incl governor
gen act_ctrl_alt=.5
replace act_ctrl_alt = 0 if  StateControl=="Dem"
replace act_ctrl_alt = 1 if  StateControl=="Rep"
label var act_ctrl_alt "State Control, incl Gov. (0 = Dem; .5 = Div.; 1 = Rep)"
gen act_ctrl_alt_align_pid = .5
replace act_ctrl_alt_align_pid = act_ctrl_alt if republican==1
replace act_ctrl_alt_align_pid  = abs(act_ctrl_alt-1) if democrat==1
label var act_ctrl_alt_align_pid  "Actual State Control (w/Gov) Aligned w/PID"

tab GovParty, gen(gov_)
drop gov_1
rename gov_2 gov_rep
gen gov_align_pid = .5
replace gov_align_pid = gov_rep if republican==1
replace gov_align_pid = abs(gov_rep-1) if democrat==1
label var gov_align_pid "Governor Aligned w/PID"


//OBSERVATIONAL INSTRUMENTAL MODELS
//Placeholder variable used in loop below
gen instrumental=.
label variable instrumental "Alignment w/Respondent (0-1)"

***CREATE CONTROL VARIABLE INTERACTIONS
foreach i of varlist age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry {
	gen XrepX`i'=dich_pid*`i'
	local label : variable label `i'
	label var XrepX`i' "Republican x `label'"
}
label var XrepXincome "Republican x Income"
label var XrepXissue_ban_abortion "Republican x Ban Abortion"
label var XrepXissue_conceal_carry "Republican x Conceal/Carry"

***Figure 2: STATE CONTROL ALIGNMENT EFFECT ESTIMATES
//Cycle through each of four measures of state alignment
foreach i in act_ctrl_align_pid gov_align_pid act_ctrl_alt_align_pid perc_ctrl_align_pid{
replace instrumental=`i'

reg mean_SR instrumental if independent==0 [aw=teamweight], r
estimates store `i'_biv
reg mean_SR age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry dich_pid XrepX* instrumental if independent==0 [aw=teamweight], r
estimates store `i' 
reg mean_SR age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry instrumental if republican == 1 [aw=teamweight], r
estimates store `i'_R
reg mean_SR age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry instrumental if democrat == 1 [aw=teamweight], r
estimates store `i'_D
}

coefplot (act_ctrl_align_pid, msymbol(O) connect(none) mcolor(black) ciopts(lcolor(black) lpattern(solid) lwidth(thin) msize(vtiny)) label(All)) (act_ctrl_align_pid_D, msymbol(Oh) mcolor(black) mlabel(label_D) mlabposition(12) connect(none) ciopts(lwidth(thin) msize(vtiny)) label(Democrats)) (act_ctrl_align_pid_R, msymbol(Oh) mcolor(black) mlabel(label_R) mlabposition(12) connect(none) ciopts(lpattern(solid) lwidth(thin) msize(vtiny)) label(Republicans)), bylabel(Party Alignment with Legislature) || (gov_align_pid) (gov_align_pid_D) (gov_align_pid_R), bylabel(Party Alignment with Governor) || (act_ctrl_alt_align_pid) (act_ctrl_alt_align_pid_D) (act_ctrl_alt_align_pid_R), bylabel(Full State Government Alignment) || (perc_ctrl_align_pid) (perc_ctrl_align_pid_D) (perc_ctrl_align_pid_R), bylabel(Perceived Alignment with State Legislature) keep(instrumental) xline(0, lcolor(black) lwidth(thin)) level(95) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xlabel(-.1(.1)1, labsize(small)) xscale(lw(none)) ylabel(none) xtitle("Relationship with Support for Policy Devolution") grid(none) yscale(lstyle(none)) ylabel(,notick)  scheme(s1mono) subtitle(, size(medsmall)) byopts(legend(off) xrescale cols(2))
graph export "F2_InstrumentalObservational.eps", as(eps) replace

//Figure SM.B3: Robustness of State Alignment to Bivariate Specification
coefplot (act_ctrl_align_pid, msymbol(O) connect(none) mcolor(black) mlabel(label_F) mlabposition(12) ciopts(lcolor(black) lpattern(solid) lwidth(thin) msize(vtiny)) label(Full Model)) (act_ctrl_align_pid_biv, msymbol(O) mcolor(black) mlabel(label_B) mlabposition(12) connect(none) ciopts(lwidth(thin) msize(vtiny)) label(Bivariate)), bylabel(Party Alignment with Legislature) || (gov_align_pid) (gov_align_pid_biv), bylabel(Party Alignment with Governor) || (act_ctrl_alt_align_pid) (act_ctrl_alt_align_pid_biv), bylabel(Full State Government Alignment) || (perc_ctrl_align_pid) (perc_ctrl_align_pid_biv), bylabel(Perceived Alignment with State Legislature) keep(instrumental) xline(0, lcolor(black) lwidth(thin)) level(95) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xlabel(-.1(.1)1, labsize(small)) xscale(lw(none)) ylabel(none) xtitle("Relationship with Support for Policy Devolution") grid(none) yscale(lstyle(none)) ylabel(,notick)  scheme(s1mono) subtitle(, size(medsmall)) byopts(legend(off) xrescale cols(2))
graph export "SM_B3_RobustInstrumentalObservational.eps", as(eps) replace


//NOTES ABOUT CORRECT PERCEPTIONS OF STATE CONTROL
//Only 51% of those in unified control correctly say so
tab perc_ctrl act_ctrl if act_ctrl!=.5 [aw=teamweight], cel
gen correct_perc=0
replace correct_perc=1 if perc_ctrl==act_ctrl  
replace correct_perc=. if act_ctrl==.5 
//"effect" of state control if correct perception 
reg mean_SR age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry std_pid dich_pid XrepX* act_ctrl_align_pid if independent==0 & correct_perc==1 [aw=teamweight], r

//"effect" of state control if not correct perception 
reg mean_SR age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other issue_ban_abortion issue_conceal_carry std_pid dich_pid XrepX* act_ctrl_align_pid if independent==0 & correct_perc==0 [aw=teamweight], r


//SM.B5-B7: STATE GOVERNMENT ALIGNMENT--REGRESSION MODELS
esttab act_ctrl_align_pid gov_align_pid act_ctrl_alt_align_pid perc_ctrl_align_pid using SM_B5_StateCtrlAll.tex, replace nogaps  order(instrumental) compress booktabs wrap varwidth(50) b(%9.3f) se(%9.3f) star(* 0.05 ** .01)  interaction(" $\times$ ") nonotes label title("State Party Control Alignment and Support for Devolution (All)"\label{StateCtrlAll}) addnote("Cell entries are unstandardized OLS coefficients; robust standard errors in parentheses. Column headers indicate measure of State Alignment used in model. $* p < .05; ** p < .01$.")  longtable 

esttab act_ctrl_align_pid_D gov_align_pid_D act_ctrl_alt_align_pid_D perc_ctrl_align_pid_D using SM_B6_StateCtrlDs.tex, replace nogaps order(instrumental) compress booktabs wrap varwidth(30) b(%9.3f) se(%9.3f) star(* 0.05 ** .01) nonotes label title("State Party Control Alignment and Support for Devolution (Democratic Identifiers)"\label{StateCtrlDs}) addnote("Cell entries are unstandardized OLS coefficients; robust standard errors in parentheses. Column headers indicate measure of State Alignment used in model. $* p < .05; ** p < .01$.")

esttab act_ctrl_align_pid_R gov_align_pid_R act_ctrl_alt_align_pid_R perc_ctrl_align_pid_R using SM_B7_StateCtrlRs.tex, replace nogaps order(instrumental) compress booktabs wrap varwidth(30) b(%9.3f) se(%9.3f) star(* 0.05 ** .01) nonotes label title("State Party Control Alignment and Support for Revolution (Republican Identifiers)"\label{StateCtrlRs}) addnote("Cell entries are unstandardized OLS coefficients; robust standard errors in parentheses. Column headers indicate measure of State Alignment used in model. $* p < .05; ** p < .01$.")


//STACKING DATA for BY-POLICY ANALYSIS
reshape long agree_state_ SR_, i(caseid) j(issue)
replace SR = (SR-1)/3
tab issue, gen(iss_)
rename iss_1 iss_mandmin
rename iss_2 iss_ab_always
rename iss_3 iss_ab_never
rename iss_4 iss_ban_assault
rename iss_5 iss_easier_conc
rename iss_6 iss_min_wage
rename iss_7 iss_work_fstamps
label var iss_mandmin "Mandatory Minimums"
label var iss_ab_always "Always Permit Abortion"
label var iss_ab_never "Never Permit Abortion"
label var iss_ban_assault "Ban Assault Rifles"
label var iss_easier_conc "Easier to Conceal/Carry"
label var iss_min_wage "Minimum Wage $15"
label var iss_work_fstamps "Food Stamp Work Req."
label var agree_state_ "Support State Outcome"
label define issues 1 "Mandatory Minimums" 2 "Always Permit Abortion" 3 "Ban Abortion" 4 "Ban Assault Weapons" 5 "Easier Conceal/Carry" 6 "Minimum Wage" 7 "Food Stamp Work Requirements"
label values issue issues

//DROP "EMPTY" OBSERVATIONS FOR GUN/ABORTION SPLIT SAMPLE + 1 case where Q was skipped
drop if SR_==.

//Figure SM.A1--Agreement w/State Outcomes Treatment FX
reg SR agree age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other std_pid iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc [aw=teamweight], cluster(caseid) 
estimates store pooled, label(Pooled)

forvalues i=1/5{
reg SR agree age educ income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other std_pid if issue==`i' [aw=teamweight], cluster(caseid)
estimates store iss_`i', label(`i')
}

coefplot pooled iss_1 iss_2 iss_3 iss_4 iss_5, mcolor(black) ciopts(color(black)) keep(agree_state_ pid) xline(0, lcolor(black) lwidth(thin)) level(95) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xlabel(none) xscale(lw(none)) ylabel(-.25(.125).25,labsize(medium)) grid(none) mcolor(black) msize(small) label vertical legend(off) xtitle("") yline(0, lcolor(black) lwidth(thin)) text(-.1 .65 "Pooled", placement(center) size(large)) text(.115 .78 "Mandatory" "Minimums", placement(center)) text(-.2 .93 "Always Permit" "Abortion", placement(center)) text(.04 1.07 "Ban" "Abortion", placement(center))  text(.10 1.22 "Ban Assault" "Rifles", placement(center))  text(-.14 1.35 "Easier to" "Conceal/Carry", placement(center)) ytitle("Effect of Agreement with Outcome" "on Support for Policy Devolution")
graph export "SM_A1_TreatmentFX.eps", as(eps) replace

//FX of AGREEMENT VARY W/PID? NO.
reg SR (agree c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc)##(independent republican) [aw=teamweight], cluster(caseid)
reg SR (agree c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc)##(c.pid) [aw=teamweight], cluster(caseid)

//Figure 1: VARIATION ACROSS ISSUES--MODELS
reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps  [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss
reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps if democrat==1 [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss_D
reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps if republican==1 [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss_R


//Figure 1: PLOT
coefplot (var_by_iss, msymbol(O) connect(none) mcolor(black) ciopts(lcolor(black) lpattern(solid) lwidth(thin) msize(vtiny)) label(All)) (var_by_iss_D, msymbol(Oh) mcolor(black) mlabel(label_D) mlabposition(12) connect(none) ciopts(lwidth(thin) msize(vtiny)) label(Democrats)) (var_by_iss_R, msymbol(Oh) mcolor(black) mlabel(label_R) mlabposition(12) connect(none) ciopts(lpattern(solid) lwidth(thin) msize(vtiny)) label(Republicans)),  level(95) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xlabel(0(.25)1, labsize(small)) xscale(lw(none)) mcolor(black) msize(small) ciopts(color(black)) coeflabels(,wrap(25)) label xtitle("Mean Support for Policy Devolution") grid(none) yscale(lstyle(none)) ylabel(,notick)  scheme(s1mono) subtitle(, size(small)) legend(off) 
graph export "F1_VarByIssue.eps", as(eps) replace

//Figure 2B: PLOT VAR BY ISSUES x STATE GOV. ALIGNMENT--MODELS
reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps if democrat==1 & act_ctrl_align_pid==1 [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss_D_align

reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps if republican==1  & act_ctrl_align_pid==1 [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss_R_align

reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps if democrat==1 & act_ctrl_align_pid==0 [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss_D_Nalign

reg SR iss_mandmin iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps if republican==1  & act_ctrl_align_pid==0 [aw=teamweight], nocons cluster(caseid)
estimates store var_by_iss_R_Nalign

***Among Republicans in D states: diff w/in domains?
reg SR iss_ab_always if republican==1  & act_ctrl_align_pid==0 & (iss_ab_always | iss_ab_never) [aw=teamweight], cluster(caseid)
reg SR iss_easier_conc if republican==1  & act_ctrl_align_pid==0 & (iss_ban_assault | iss_easier_conc ) [aw=teamweight], cluster(caseid)

//Output Figure 2B: PLOT VAR BY ISSUES x STATE GOV. ALIGNMENT
coefplot (var_by_iss_D_Nalign, msymbol(O) mcolor(black) mlabel(label_D) mlabposition(12) connect(none) ciopts(lwidth(thin) msize(vtiny)) label(Democrats)) (var_by_iss_R_align, msymbol(O) mcolor(black) mlabel(label_R) mlabposition(12) connect(none) ciopts(lpattern(solid) lwidth(thin) msize(vtiny)) label(Republicans)) ,  level(95) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xlabel(0(.25)1, labsize(small)) xscale(lw(none)) mcolor(black) msize(small) ciopts(color(black)) coeflabels(,wrap(25)) label xtitle("Mean Support for Policy Devolution") grid(none) yscale(lstyle(none) r(0.2 7.8)) ylabel(,notick)  scheme(s1mono) subtitle(, size(small)) legend(off) 
graph export "F2A_VarByIssue_R_States.eps", as(eps) replace

coefplot (var_by_iss_D_align, msymbol(O) mcolor(black) mlabel(label_D) mlabposition(12) connect(none) ciopts(lwidth(thin) msize(vtiny)) label(Democrats)) (var_by_iss_R_Nalign, msymbol(O) mcolor(black) mlabel(label_R) mlabposition(12) connect(none) ciopts(lpattern(solid) lwidth(thin) msize(vtiny)) label(Republicans)),  level(95) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xlabel(0(.25)1, labsize(small)) xscale(lw(none)) mcolor(black) msize(small) ciopts(color(black)) coeflabels(,wrap(25)) label xtitle("Mean Support for Policy Devolution") grid(none) yscale(lstyle(none) r(0.2 7.8)) ylabel(,notick)  scheme(s1mono) subtitle(, size(small)) legend(off) 
graph export "F2B_VarByIssue_D_States.eps", as(eps) replace


//Figure SM.B2: "EFFECT" OF PID BY ISSUE
foreach i in mandmin ab_always ab_never ban_assault easier_conc min_wage work_fstamps{
	gen pidX`i'=std_pid*iss_`i'
	gen independentX`i'=independent*iss_`i'
	gen republicanX`i'=republican*iss_`i'
	local label : variable label iss_`i'
    label variable pidX`i' "`label'"
    label variable independentX`i' "`label'"
    label variable republicanX`i' "`label'"
}

reg SR c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps independentX* republicanX* i.inputstate [aw=teamweight], cluster(caseid)
estimates store pid_by_issue_noideol

reg SR c.age c.educ c.income income_mis woman gend_other r_black r_hisp r_asian r_multiple r_other iss_ab_always iss_ab_never iss_ban_assault iss_easier_conc iss_min_wage iss_work_fstamps independentX* republicanX* i.inputstate if act_ctrl==0 [aw=teamweight], cluster(caseid)
estimates store pid_by_issue_align_comp

coefplot (pid_by_issue_noideol, msymbol(O) connect(none) mcolor(black) ciopts(lcolor(black) lpattern(solid) lwidth(thin) msize(vtiny)) label(All States)) (pid_by_issue_align_comp, msymbol(S) connect(none) mcolor(black) ciopts(lcolor(black) lpattern(solid) lwidth(thin) msize(vtiny)) label(Democrat States)), level(95) keep(republicanX*) graphregion(fcolor(white) lcolor(none) ilcolor(none) color(white) ) xscale(lw(none)) mcolor(black) msize(small) label xtitle("Coefficient on Republican Indicator") legend(off) grid(none) xlabel(,nogrid)  xline(0, lcolor(black) lwidth(thin))  text(.70 .20 "Demographic Controls" "(All States)", placement(center) size(small))  text(1.25 .465 "Demographic Controls" "(Dem. States Only)", placement(center) size(small))
graph export "SM_B2_PIDByIssue.eps", as(eps) replace

